import request from '@/utils/request'
import type { ApiResponse } from './user'

export interface RouteItem {
  id?: number;
  path: string;
  name: string;
  component: string;
  title: string;
  icon?: string;
  parentId?: number;
  sort: number;
  hidden?: boolean;
  createTime?: string;
}

// 获取路由列表
export const getRoutes = () => {
  return request.get<ApiResponse<RouteItem[]>>('/api/routes')
}

// 添加路由
export const addRoute = (data: RouteItem) => {
  return request.post<ApiResponse<RouteItem>>('/api/route', data)
}

// 更新路由
export const updateRoute = (data: RouteItem) => {
  return request.put<ApiResponse<RouteItem>>(`/api/route/${data.id}`, data)
}

// 删除路由
export const deleteRoute = (id: number) => {
  return request.delete<ApiResponse<null>>(`/api/route/${id}`)
} 